/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../mixins/input.less';
@import '../mixins/common.less';
@import '../custom.less';
@import './vars.less';

@textarea-prefix-cls: ~'@{css-prefix}mobile-textarea';
@input-prefix-cls: ~'@{css-prefix}mobile-input';
@input-group-prefix-cls: ~'@{css-prefix}mobile-input-group';
@input-form-prefix-cls: ~'@{css-prefix}mobile-input-form';

.@{textarea-prefix-cls} {
  position: relative;
  display: inline-block;
  width: 100%;
  background-color: var(--ti-mobile-input-bgcolor, #fff);
  padding: 12px 16px;

  &__count {
    color: var(--ti-mobile-textarea-count-color, #999);
    font-size: var(--ti-mobile-textarea-count-font-size, 12px);
    margin-top: 4px;
    text-align: right;
    display: block;
  }

  &__inner {
    width: 100%;
    height: var(--ti-mobile-textarea-inner-height, 96px);
    font-size: var(--ti-mobile-textarea-inner-font-size, 16px);
    color: var(--ti-mobile-textarea-inner-color, #666);
    padding: 0;
    border: 0;
    display: block;
    resize: none;
    box-sizing: border-box;
    transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    .placeholder(
      @color: var(--ti-mobile-textarea-inner-placeholder-color, #ccc)
    );

    &:hover,
    &:focus {
      outline: 0;
    }
  }

  &__title {
    font-size: var(--ti-mobile-textarea-title-font-size, 16px);
    color: var(--ti-mobile-textarea-title-color, #333);
    margin-bottom: 8px;
  }

  &__content {
    margin-bottom: 8px;
  }

  &.is-showlimit {
    padding-bottom: 8px;
  }

  &.is-showtitle &__inner {
    height: var(--ti-mobile-textarea-showlimit-inner-height, 70px);
  }

  &.is-showcontent &__inner {
    height: var(--ti-mobile-textarea-showcontent-inner-height, 66px);
  }

  &.is-disabled &__inner {
    background-color: var(--ti-mobile-input-disabled-bgcolor, #f5f5f5);
    color: var(--ti-mobile-input-disabled-color, #999);
    cursor: not-allowed;
  }

  &.is-exceed &__count {
    color: var(--ti-mobile-input-exceed-color, #f5222d);
  }
}

.@{input-prefix-cls} {
  position: relative;
  width: 100%;

  &::-webkit-scrollbar {
    z-index: 11;
    width: 6px;

    &:horizontal {
      height: 6px;
    }
  }

  &::-webkit-scrollbar-thumb {
    border-radius: 5px;
    width: 6px;
    background: #b4bccc;
  }

  &::-webkit-scrollbar-corner {
    background: #fff;
  }

  &::-webkit-scrollbar-track {
    background: #fff;
  }

  &::-webkit-scrollbar-track-piece {
    background: #fff;
    width: 6px;
  }

  &.is-exceed &__suffix &__count {
    color: var(--ti-mobile-input-exceed-color, #f5222d);
  }

  &.is-disabled &__inner {
    cursor: not-allowed;
    color: var(--ti-mobile-input-disabled-color, #999);
    background: var(--ti-mobile-input-disabled-bgcolor, #f5f5f5);
  }

  &.is-disabled &__icon {
    cursor: not-allowed;

    &.@{css-prefix}svg {
      &,
      &:hover {
        fill: var(--ti-mobile-input-disabled-color, #999);
      }
    }
  }

  &.is-disabled &__prefix,
  &.is-disabled &__suffix {
    .@{css-prefix}svg {
      &,
      &:hover {
        fill: var(--ti-mobile-input-disabled-color, #999);
      }
    }
  }

  & &__clear {
    font-size: var(--ti-mobile-input-icon-font-size, 16px);
    cursor: pointer;
    transition: color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);

    &,
    &:hover {
      fill: var(--ti-mobile-input-disabled-color, #999);
    }
  }

  & &__count {
    height: 100%;
    display: inline-flex;
    align-items: center;
    color: #909399;
    font-size: 12px;

    .@{input-prefix-cls}__count-inner {
      background: var(--ti-mobile-input-bgcolor, #fff);
      line-height: initial;
      display: inline-block;
    }
  }

  &__inner {
    width: 100%;
    height: 48px;
    line-height: 48px;
    font-size: 16px;
    color: #666;
    background: var(--ti-mobile-input-bgcolor, #fff);
    padding: 0 16px;
    border: 0;
    outline: 0;
    display: inline-block;
    box-sizing: border-box;
    -webkit-appearance: none;
    transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    .placeholder(@color: #ccc);

    &:hover,
    &:focus,
    &:active {
      outline: 0;
    }

    &::-ms-clear {
      display: none;
      width: 0;
      height: 0;
    }
  }

  &__prefix,
  &__suffix {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.3s;
    text-align: center;
    color: #d9d9d9;
    line-height: calc(var(--ti-mobile-input-height, 30px) - 2px);
  }

  &.is-active &__inner,
  &__inner:focus {
    outline: 0;
  }

  &__suffix {
    right: 16px;
    transition: all 0.3s;
    pointer-events: none;

    &:hover {
      cursor: pointer;
    }
  }

  &__suffix-inner {
    pointer-events: all;
  }

  &__prefix {
    left: 8px;
    transition: all 0.3s;
    font-size: var(--ti-mobile-input-icon-font-size, 16px);
  }

  &__icon {
    height: 100%;
    line-height: var(--ti-mobile-input-height, 30px);
    text-align: center;
    transition: all 0.3s;
    font-size: var(--ti-mobile-input-icon-font-size, 16px);

    &,
    &:hover {
      fill: var(--ti-mobile-input-disabled-color, #999);
    }

    &:after {
      content: '';
      height: 100%;
      width: 0;
      display: inline-block;
      vertical-align: middle;
    }

    .svg-operationfaild {
      &,
      &:hover {
        fill: var(--ti-mobile-input-icon-close-color, #bfbfbf);
      }
    }
  }

  &__validateIcon {
    pointer-events: none;
  }

  &-suffix &__inner {
    padding-right: 48px;
  }

  &-prefix &__inner {
    padding-left: 30px;
    padding-right: 28px;
  }

  &-medium {
    .input-size(var(--ti-mobile-input-medium-height, 42px));
  }

  &-small {
    .input-size(var(--ti-mobile-input-small-height, 36px));
  }

  &-mini {
    .input-size(var(--ti-mobile-input-mini-height, 24px));
  }
}

.@{input-group-prefix-cls} {
  line-height: normal;
  display: inline-table;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;

  > .@{input-prefix-cls}__inner {
    vertical-align: middle;
    display: table-cell;
  }

  &__append,
  &__prepend {
    background-color: #f5f5f5;
    color: #999;
    padding: 0 20px;
    width: 1px;
    vertical-align: middle;
    display: table-cell;
    position: relative;
    white-space: nowrap;

    &:focus {
      outline: 0;
    }

    .@{css-prefix}button,
    .@{css-prefix}select {
      display: inline-block;
      margin: -10px -20px;
    }

    .@{css-prefix}button,
    .@{css-prefix}input {
      font-size: inherit;
    }

    button.@{css-prefix}button,
    div.@{css-prefix}select .@{input-prefix-cls}__inner,
    div.@{css-prefix}select:hover .@{input-prefix-cls}__inner {
      background-color: transparent;
      color: inherit;
    }
  }
}

.@{input-form-prefix-cls} {
  height: 48px;
  line-height: 48px;
  position: relative;

  &.isVertical:after {
    content: '';
    display: block;
    height: 0;
    width: 100%;
    border-bottom: 1px solid #ddd;
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 1;
  }

  &__select {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    height: 100%;
    background: var(--ti-mobile-input-bgcolor, #fff);
  }

  &__icon {
    height: 20px;
    line-height: 20px;
    width: 20px;
    margin-right: 16px;
    font-size: 0;
    transform-origin: center center;
    transition: all linear 0.3s;

    svg {
      fill: #999;
      font-size: 20px;
      vertical-align: text-bottom;
    }
  }

  &__label {
    box-sizing: border-box;
    width: 35%;
    padding: 0 12px 0 16px;
    line-height: 1.376;
    color: #333;
    font-size: 22px;
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  &__input {
    width: 65%;
    float: right;
  }

  &__tips {
    width: 100%;
    color: var(--ti-mobile-textarea-count-color, #999);
    padding-top: 6px;
    line-height: 20px;
  }

  &__error {
    position: relative;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.416;
    color: #f36f64;
    text-overflow: ellipsis;
    padding: 0px 16px 0 16px;

    &.align-right {
      text-align: right;
    }

    &.align-left {
      text-align: left;
    }
  }
}

.@{css-prefix-iconfont}-loading {
  font-size: 14px;
  line-height: 1;
  vertical-align: text-top;
  animation: rotating 2s linear infinite;
}

@keyframes rotating {
  0% {
    transform: rotateZ(0deg);
  }

  100% {
    transform: rotateZ(360deg);
  }
}
